// pages/mac/mac.js
const {Thedefaultpage} = require('../../utils/util')
Page({

   /**
    * 页面的初始数据
    */
   data: {
      id:'',
      url:'hhttp://img.9lele.com',
      shopping_1:[],
      shopping: [
         {img:'/static/head/RL}T8Q}CXL41A8QALVR]5N7.png',title:'Aple MacBook Air 13.3新款八核 M1芯片',title_1:'本店笔记本热销第二名',price:7999,good:'1.7w+好评',good_1:'好评95%'},
         {img:'/static/head/RL}T8Q}CXL41A8QALVR]5N7.png',title:'Aple MacBook Air 13.3新款八核 M1芯片',title_1:'本店笔记本热销第二名',price:7999,good:'1.7w+好评',good_1:'好评95%'},
         {img:'/static/head/RL}T8Q}CXL41A8QALVR]5N7.png',title:'Aple MacBook Air 13.3新款八核 M1芯片',title_1:'本店笔记本热销第二名',price:7999,good:'1.7w+好评',good_1:'好评95%'},
         {img:'/static/head/RL}T8Q}CXL41A8QALVR]5N7.png',title:'Aple MacBook Air 13.3新款八核 M1芯片',title_1:'本店笔记本热销第二名',price:7999,good:'1.7w+好评',good_1:'好评95%'},
         {img:'/static/head/RL}T8Q}CXL41A8QALVR]5N7.png',title:'Aple MacBook Air 13.3新款八核 M1芯片',title_1:'本店笔记本热销第二名',price:7999,good:'1.7w+好评',good_1:'好评95%'},
         {img:'/static/head/RL}T8Q}CXL41A8QALVR]5N7.png',title:'Aple MacBook Air 13.3新款八核 M1芯片',title_1:'本店笔记本热销第二名',price:7999,good:'1.7w+好评',good_1:'好评95%'},
        ],
        list:''
   },

   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
      console.log(options.id);
      this.setData({
        list:options.id,
        id:options.id
      })
   },

   /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady: function () {
    if(this.data.list == 1){
      wx.setNavigationBarTitle({
         title: 'Mac'
       })
    }
    else if(this.data.list == 2){
      wx.setNavigationBarTitle({
         title: 'iPad'
       })
    }
    else if(this.data.list == 3){
      wx.setNavigationBarTitle({
         title: 'iPone'
       })
    }
    else if(this.data.list == 4){
      wx.setNavigationBarTitle({
         title: 'Watch'
       })
    }
    else if(this.data.list == 5){
      wx.setNavigationBarTitle({
         title: 'Music'
       })
    }
    else if(this.data.list == 6){
      wx.setNavigationBarTitle({
         title: '配件'
       })
    }
      
   },

   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
      this.Thedefaultpage();
   },
   Thedefaultpage(){
      let that = this
      let id = that.data.id
      wx.request({
         url: Thedefaultpage(id ), //仅为示例，并非真实的接口地址
         header: {
           'content-type': 'application/json' // 默认值
         },
         success (res) {
           console.log(res.data)
           that.setData({
               shopping_1:res.data.data
            })
         }
       })
   },

   /**
    * 生命周期函数--监听页面隐藏
    */
   onHide: function () {

   },

   /**
    * 生命周期函数--监听页面卸载
    */
   onUnload: function () {

   },

   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {

   },

   /**
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {

   },

   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {

   }
})